package com.itheima.reggie.common;


//自动自动填充获取当前用户
//基于threadlocal封装工具类，用户保存和获取当前登录ID
//工具类一般时静态
public class BaseContext {
    //threadlocal只有一个，每个线程在里面只有一个小区域
    private static  ThreadLocal<Long> threadLocal =new ThreadLocal<>();

    public static void  setCurrentId(Long id){
        threadLocal.set(id);
    }

    public static  Long getCurrentId(){
        return (Long)threadLocal.get();
    }

    public static void remove(){
        threadLocal.remove();
    }
}
